home *** CD-ROM | disk | FTP | other *** search
/ Aminet 15 / Aminet 15 - Nov 1996.iso / Aminet / disk / cdrom / Atapi_PnP300.lha / atapi_pnp300 / developer_kit / PlayLSN.c < prev    next >
C/C++ Source or Header  |  1996-01-27  |  3KB  |  92 lines

  1. /****************************************************************************
  2. *
  3. *
  4. *   $VER: PlayLSN.c  1.0 (22 Jan 1996) by M_Campinoti CD++
  5. *
  6. *   $HISTORY:
  7. *
  8. *   22 Jan 1996 : 001.000 : First and Last release of an example that show
  9. *                           how to play audio tracks by means of
  10. *                           CD_PLAYLSN command.
  11. *                           Didactical use, so CLI only      :)
  12. *
  13. ****************************************************************************/
  14.  
  15. #include <proto/exec.h>
  16. #include <exec/devices.h>
  17. #include <exec/io.h>
  18.  
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21.  
  22. #include "atapi_cd.h"
  23.  
  24.  
  25. /**********************************************************************************/
  26. /* Here the fornula to calculate the right LSN starting by Minutes,Seconds,Frames */
  27. /* Length = minutes*(60*75) + seconds*75 + frames                                 */
  28. /*                                                                                */
  29. /*                   minutes  , seconds , frames  to play (default 1m,1sec,1fr)   */
  30. #define DEF_LENGTH ( 01*(60*75) + 01*75 + 01)
  31. /**********************************************************************************/
  32.  
  33. main (UBYTE argc,UBYTE** argv)
  34. {
  35.     struct IOStdReq      *ioreq = NULL ;
  36.     struct MsgPort       *reply = NULL ;
  37.     ULONG                lsn_start;
  38.     ULONG                lsn_length;
  39.  
  40.     switch(argc)
  41.     {
  42.      case 0:
  43.          return;         /* it came from workbench .... */
  44.          break;
  45.      case 1:
  46.          printf("USAGE: PlayLSN <LSN_start> <LSN_Length>\n");
  47.          return;        /* Yes, this isn't a cool template, but is quickly ! (i'm lazy) */
  48.          break;
  49.      case 2:
  50.          lsn_start=atoi(argv[1]);
  51.          lsn_length=DEF_LENGTH;
  52.          break;
  53.      case 3:
  54.          lsn_start=atoi(argv[1]);
  55.          lsn_length=atoi(argv[2]);
  56.      default:
  57.          break;
  58.     }
  59.  
  60.  
  61.     if( reply = CreateMsgPort() )
  62.     {
  63.       if( ioreq = (struct IOStdReq *)
  64.              CreateIORequest(reply ,sizeof(struct  IOStdReq)) )
  65.       {
  66.         if(!OpenDevice("cd.device",0,(struct IORequest*)ioreq,NULL) )
  67.         {
  68.           ioreq->io_Command = CD_PLAYLSN;
  69.           ioreq->io_Offset  = lsn_start;
  70.           ioreq->io_Length  = lsn_length;
  71.  
  72.           SendIO((struct IORequest*)ioreq);
  73.           
  74.           if (!ioreq->io_Error)                   /* Command succeeded        */
  75.           {
  76.            printf("Start Playing at requested LSN ...\n");
  77.            WaitIO((struct IORequest*)ioreq);
  78.           }
  79.           else printf("I/O error !\n");     /* analyze ioreq->io_Error to know what kind ... */
  80.                                             /* ... see atapi_cd.h for #defines of it !       */
  81.           
  82.           CloseDevice((struct IORequest *)ioreq) ;
  83.         }
  84.         
  85.         DeleteIORequest(ioreq) ;
  86.       }
  87.  
  88.       DeleteMsgPort(reply);
  89.     }
  90. }
  91.  
  92.